package com.neutech.neureg.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.neutech.neureg.service.RegisterService;
import com.neutech.po.Register;
import com.neutech.vo.ViewObject;

@RestController
@RequestMapping("/reg")
public class RegisterController {
	@Autowired
	private RegisterService registerService;
	/**
	 * 点击挂号，添加挂号信息
	 * @param map
	 * @return:ViewObject,当result=1时，status为200，添加挂号信息成功；否则，添加失败
	 */
	@RequestMapping(value="/toAddRegisterInfo",method=RequestMethod.POST)
	public ViewObject addRegisterInfo(@RequestBody Map<String,Object> map){
		System.out.println(map.get("realName"));
		int result = registerService.addRegisterInfo(map);
		if(result == 1){
			return new ViewObject("200","success");
		}else{
			return new ViewObject("403","failure");
		}
	}
	/**
	 * 刷新初始化挂号页面时，就要显示病历号
	 * @return:整体返回register的实体Bean，再在前端调用病历号CaseNumber
	 */
	@RequestMapping("/toGetMaxCsNo")
	public Register getRegisterInfo(){
		return registerService.getRegisterBean();
	}
}
